<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>权限管理</title>
    <link rel="stylesheet" href="__STATICS__/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATICS__/css/public.css" media="all">
    <style>
        .layui-btn:not(.layui-btn-lg ):not(.layui-btn-sm):not(.layui-btn-xs) {
            height: 34px;
            line-height: 34px;
            padding: 0 8px;
        }
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field site-demo-button" style="margin-top: 30px;">
            <legend>操作</legend>
            <div style="margin:10px 20px;">
                <button type="button" class="layui-btn layui-btn-sm" lay-demo="setChecked">全选</button>
            </div>
        </fieldset>
    </div>
    <table id="tree" class="layui-table" ></table>

    <form class="layui-form layui-form-pane" lay-filter="form">
        <div class="layui-form-item">
            <div class="layui-input-inline">

                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
                <a href="{:url('index')}" class="layui-btn layui-btn-primary">返回</a>
            </div>
        </div>
    </form>
</div>



<script src="__STATICS__/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__STATICS__/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['tree','form'], function(){
        var $   =  layui.jquery,
            tree = layui.tree,
            form = layui.form;

        //渲染
        tree.render({
          elem: '#tree'  //绑定元素
          ,showCheckbox: true  //是否显示复选框
          ,id: 'id'
          ,data:{:json_encode($RoleAccessTree)}
        });
        //tree.setChecked('id',[7,13]);

        form.on('submit(submit)', function (data) {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            var data  = tree.getChecked('id');
            $.post("", {access:data,role_id:2}, function (res) {
                layer.close(loading);
                if (res.code > 0) {
                    layer.msg(res.msg, {time: 1800, icon: 1}, function () {
                        location.href = res.url;
                    });
                } else {
                    layer.msg(res.msg, {time: 1800, icon: 2});
                }
            });
        });

    });


</script>
</body>
</html>